package cn.itcast.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.springframework.stereotype.Component;


public class WxHashedCredentialsMatcher extends HashedCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken authenticationToken, AuthenticationInfo info) {
        WxOpenIdToken wxToken = (WxOpenIdToken) authenticationToken;
        if(null != wxToken.getPrincipal()){//这里返回true跳过密码验证
            return true;
        }
        return super.doCredentialsMatch(wxToken, info);
    }

}